/**
 *  @file Inflater.h
 */
#ifndef _INFLATER_H_
#define _INFLATER_H_

#include "../../common/BaseObject.h"
#include "../../io/Stream.h"
#include "../../collections/ArrayT.h"

namespace cppflib
{

namespace util
{

namespace zip
{

class ZlibInfo;

/**
 *  Class to decompress data using the DFLATE algorithm
 *  Data can be wrapped around with 'zlib', 'gzip' or even no header
 */
class _DLLAPI Inflater : public BaseObject
{
private:
    ZlibInfo *pZlibInfo;
 
private:
    Inflater(void);
    void ReleaseBeforeThrowing();

public:
   //! header type
   typedef enum _headertype
   {
      NO_HEADER,   // raw DEFLATE data
      AUTODETECT,  // auto detect a zlib or gzip header
   } headertype_t;

   explicit Inflater(headertype_t type);    
   virtual ~Inflater(void);

   void SetInputStream(io::Stream *pStream);
   void SetInputStream(io::Stream *pStream, sz_t streamLength);
   int Inflate(collections::ArrayByte &buffer);
   int Inflate(collections::ArrayByte &buffer, int offset, int count); 
};

} // end of namespace zip

} // end of namespace util

} // end of namespace cppflib

#endif

